package com.yupi.usercenter.exception;

import com.yupi.usercenter.common.ErrorCode;

/**
 * Classname: BusinessException
 * Package: com.yupi.usercenter.exception
 * Description:
 * 自定义异常类
 * @Author Alex Liang
 * @Create 2024/8/18 下午5:30
 * @Version 1.0
 */

public class BusinessException extends RuntimeException{

    private final int code;

    private final String description;

    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMesssage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMesssage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
